﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 项目
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.play();
            if (button1.Text == "播放")
            {
                axWindowsMediaPlayer1.Ctlcontrols.play();
                button1.Text = "暂停";
            }
            else if (button1.Text == "暂停") {
                axWindowsMediaPlayer1.Ctlcontrols.pause();
                button1.Text = "播放";

            }
        }



        private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.settings.autoStart = false;
            axWindowsMediaPlayer1.URL = "";
        }
        List<string> list = new List<string>();
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "*.avi|*.avi|*.mp3文件|*.mp3|.所有文件|*.*";
            ofd.Multiselect = true;
            ofd.ShowDialog();
            string[] path = ofd.FileNames;
            for (int i = 0; i < path.Length; i++)
            {
                list.Add(path[i]);
                listBox1.Items.Add(Path.GetFileName(path[i]));

            }
                }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            if (listBox1.Items.Count==0)
            {
                MessageBox.Show("请选择音乐文件");
                return;
            }
            try
            {



                axWindowsMediaPlayer1.URL = list[listBox1.SelectedIndex];
                axWindowsMediaPlayer1.Ctlcontrols.play();
                button1.Text = "暂停";
            }
            catch { }
        }

        private void button4_Click(object sender, EventArgs e)
        {

            int index = listBox1.SelectedIndex;
            listBox1.SelectedIndices.Clear();
            index++;
            if (index==listBox1.Items.Count)
            {
                index = 0;
            }
            listBox1.SelectedIndex = index;
            axWindowsMediaPlayer1.URL = list[index];
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int index = listBox1.SelectedIndex;
            listBox1.SelectedIndices.Clear();
            index--;
            listBox1.SelectedIndex = index;
            axWindowsMediaPlayer1.URL = list[index];
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ////空间发挥好那你发 看
            //坐看行程表孙德按键上的不爱好的白好的吧
        }
    }
    }

